<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app";
import { ref } from "vue";
import { articleDetail } from "@/api/user";
import { interpreter } from "@/api/request";

const nodes = ref({
  create_time: "",
  title: "",
  content: "",
  read_total: 0,
  author: ""
});

onLoad(async (options: any) => {
  if (options?.news_id) {
    const [err, res] = await interpreter(articleDetail(options?.news_id));
    if (!err) {
      nodes.value = res;
    }
  }
});
</script>

<template>
  <view class="bg">
    <view class="title">
      {{ nodes.title }}
    </view>
    <Flex class="info" justify="space-between">
      <text>{{ nodes.author }} &nbsp; {{ nodes.create_time }}</text>
      <text>浏览量{{ nodes.read_total }}</text>
    </Flex>
    <!-- <text>{{ nodes.content }}</text> -->
    <rich-text :nodes="nodes.content"></rich-text>
  </view>
</template>

<style lang="scss" scoped>
.bg {
  padding: 16px 16px 8px;
}
.title {
  font-size: 20px;
  color: #19191c;
  font-weight: 400px;
  margin-bottom: 16px;
  margin-top: 16px;
}
.info {
  font-size: 12px;
  color: #a0a3b5;
  margin-bottom: 8px;
}
</style>
